﻿#pragma once
#include "cs_datatype.h"
class CmdWorker:public Buff_Reader
{
public:
	CmdWorker(void);
	virtual ~CmdWorker(void);
	void coming(OS_TcpSocket tcc)
	{
		header hd;
		int len;
		bool cod = true;
		while (cod)
		{
			memset(&hd, 0, sizeof(hd));
			len =  tcc.Recv(&hd,sizeof(hd));
			if ( len == sizeof(hd))
			{
				printf("收到数据(len: %d, cmd: 0x%x, bufflen: %d)\r\n", len, hd.cmd, hd.buff);
				if (hd.cmd == HT_OVER)
				{
					tcc.Close();
					cod = false;
					break;
				}else
				{
					cmdprocess(tcc,hd);
				}

			}	
			else if (len <= 0)
			{
				tcc.Close();
				cod = false;
			}
			
		}
	}
	void cmdprocess(OS_TcpSocket tcc, header hd);
};

